import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import './plugins/element.js'
/* 全局样式 */
import './assets/css/global.css'
/* 字体图标 阿里图标库 */
import './assets/fonts/iconfont.css'
/* 副文本编辑器 */
import VueQuillEditor from 'vue-quill-editor'
import 'quill/dist/quill.core.css' // import styles
import 'quill/dist/quill.snow.css' // for snow theme
import 'quill/dist/quill.bubble.css' // for bubble theme
Vue.use(VueQuillEditor)
/* table插件 */
import TreeTable from 'vue-table-with-tree-grid'
Vue.component('tree-table',TreeTable)

/* axios全局配置 */
import axios from 'axios'
/* 配置根路径 */
axios.defaults.baseURL = 'http://127.0.0.1:9001/api/private/v1/'
axios.interceptors.request.use(config =>{
  config.headers.Authorization = window.sessionStorage.getItem('token')
  //console.log(window.sessionStorage.getItem('token'))
  return config
})
Vue.prototype.$http = axios


/* 全局时间过滤器 */
Vue.filter('dataFormat',function (oldtime) {
  const time = new Date(oldtime)
  const year = time.getFullYear()
  const month = (time.getMonth() + 1)>10?(time.getMonth() + 1):'0'+(time.getMonth() + 1)
  const day  = time.getDate()>10 ? time.getDate() : '0'+time.getDate()
  const hour = time.getHours() >10 ? time.getHours():'0'+time.getHours()
  const min = time.getMinutes() >10 ? time.getMinutes():'0'+time.getMinutes()
  const sec = time.getSeconds() >10 ? time.getSeconds():'0'+time.getSeconds()
  return `${year}-${month}-${day} ${hour}:${min}:${sec}`
})

Vue.config.productionTip = false

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
